package me.helllp.dake.iam.core.auth;

import me.helllp.dake.iam.core.bean.DakeAuthTicket;

import java.util.ArrayList;
import java.util.List;

public class AuthFilterRegistry {
    private final List<AuthFilter> registrations = new ArrayList();

    public void registry(AuthFilter authFilter) {
        registrations.add(authFilter);
    }

    public List<AuthFilter> getAuthFilters() {
        return registrations;
    }

    public boolean doFilter(DakeAuthTicket authTicket) {
        for(AuthFilter filter : registrations) {
            if (filter.doFilter(authTicket)) {
                filter.postFilter(authTicket);
            } else {
                return false;
            }
        }
        return true;
    }
}
